Skip to content

Harden HTTP bridge previous_response_id continuity recovery#301

Open
JoshuaRileyDev wants to merge 1 commit intoSoju06:mainfrom
JoshuaRileyDev:codex/harden-http-bridge-previous-response-recovery
Open

Harden HTTP bridge previous_response_id continuity recovery#301
JoshuaRileyDev wants to merge 1 commit intoSoju06:mainfrom
JoshuaRileyDev:codex/harden-http-bridge-previous-response-recovery

Conversation

@JoshuaRileyDev
Copy link
Copy Markdown

@JoshuaRileyDev JoshuaRileyDev commented Apr 2, 2026

Summary

  • add a bridge-local previous-response recovery index keyed by (response.id, api_key)
  • recover live HTTP bridge sessions for follow-up requests carrying previous_response_id before fail-closed continuity errors
  • clean up previous-response mappings when bridge sessions close
  • add integration coverage for recovery when request affinity drifts between turns
  • add OpenSpec change artifacts for this behavior update

Validation

  • uv run pytest -q tests/integration/test_http_responses_bridge.py -k "missing_turn_state_alias_with_previous_response_id_fails_closed or recovers_previous_response_without_turn_state_alias or send_failure_returns_previous_response_not_found"
  • result: 3 passed

@Soju06
Copy link
Copy Markdown
Owner

Soju06 commented Apr 3, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1960fa902

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2557 to +2558
if response_id is not None and matched_request_state is not None:
await self._register_http_bridge_previous_response_id(session, response_id)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Index response IDs for terminal events without created

_process_http_bridge_upstream_text only writes to _http_bridge_previous_response_index when matched_request_state is set, but the function explicitly supports a fallback where response.created is missing and _pop_terminal_websocket_request_state(...) resolves the request at terminal time. In that fallback, matched_request_state stays None, so successful responses with a terminal response.id are never indexed, and a follow-up request using that previous_response_id can incorrectly fail with previous_response_not_found even though continuity is still live.

Useful? React with 👍 / 👎.

Comment on lines +1618 to +1619
if previous_response_id is not None and inflight_future is None and (
existing is None or existing.closed or existing.account.status != AccountStatus.ACTIVE
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recover by previous_response_id despite inflight key creation

This guard blocks previous-response recovery whenever an inflight session future exists for the request-derived key, and the method then sets a continuity error for any request with previous_response_id. That means a valid mapped live session can be ignored during concurrent traffic (for example, another request is currently creating a session for the same prompt-cache key), causing a false 400 continuity failure instead of reusing the known session.

Useful? React with 👍 / 👎.

@imadtg
Copy link
Copy Markdown

imadtg commented Apr 3, 2026

does this solve #221?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants